package com.sen.common.widget.table;

import java.util.List;

import org.apache.commons.collections.CollectionUtils;

import com.sen.common.widget.Component;

/**
 * @author sen
 */
public class TableRow extends Component {
	
	private Table table;
	
	public TableRow(Table table) {
		this(null, table);
	}
	
	public TableRow(String id, Table table) {
		super("tr");
		this.id(id);
		this.table = table;
	}
	
	public TableRow cell(String content) {
		cell(new TableCell().content(content));
		return this;
	}
	
	public TableRow cell(TableCell cell) {
		this.add(cell);
		return this;
	}
	
	public TableRow cells(List<TableCell> cells) {
		if (CollectionUtils.isEmpty(cells)) {
			return this;
		}
		for (TableCell cell : cells) {
			this.cell(cell);
		}
		return this;
	}
	
	public Table back() {
		return table;
	}
}
